package org.jeecg.modules.demo.sermanager.task;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.demo.sermanager.entity.NetptDetectionRet;
import org.jeecg.modules.demo.sermanager.entity.NetptJobRet;
import org.jeecg.modules.demo.sermanager.service.INetptDetectionRetService;
import org.jeecg.modules.demo.sermanager.service.INetptJobRetService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @description
 * @date 2022/1/24  16:35
 * @Author :JIE
 */
@Slf4j
public class NetJob implements Job {

    @Autowired
    private INetptJobRetService netptJobRetService;
    @Autowired
    private INetptDetectionRetService iNetptDetectionRetService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        List<NetptJobRet> list=netptJobRetService.findNetptJobRetList();
        for(NetptJobRet entity:list){
            String ret="失败";
            List<NetptDetectionRet> deteRetList=iNetptDetectionRetService.selectByMainId(entity.getDetectionId());
            for(NetptDetectionRet deteRet:deteRetList){
                if(entity.getReturnInfo().contains(deteRet.getMatchResult())){
                    ret="成功";
                    break;
                }
            }
            entity.setDetectionResult(ret);
            netptJobRetService.updateById(entity);
        }
    }
}
